package com.david.api;

import com.david.annotation.ApiVersion;
import com.david.annotation.IgnoreAuth;
import com.david.annotation.LoginUser;
import com.david.entity.UserEntity;
import com.david.utils.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

/**
 * API测试接口
 *
 * Created by chendawei on 2017/6/7.
 */
@RestController
@RequestMapping("/api/{version}/")
public class ApiTestController {

    /**
     * 获取用户信息
     */
    @GetMapping("userInfo")
    @ApiVersion (1)
    public R userInfo(@LoginUser UserEntity user){
        Map<String,Object> map = new HashMap<> ( );
        map.put ("test", "com/david" );
        String str = null;
        List list = new ArrayList ();
        list = Collections.emptyList ();
        Boolean boolvaule = null;
        Integer intValue  = null;
        map.put ( "ss",str );
        map.put ( "list",list );
        map.put ( "boolvaule",boolvaule );
        map.put ( "intValue",intValue );
        return R.ok().put("user", user).put ( "object",map );
    }

    /**
     * 忽略Token验证测试
     */
    @IgnoreAuth
    @GetMapping("notToken")
    @ApiVersion (1)
    public R notToken1(){
        return R.ok().put("msg", "无需token也能访问。。。版本1");
    }

    /**
     * 忽略Token验证测试
     */
    @IgnoreAuth
    @GetMapping("notToken")
    @ApiVersion (2)
    public R notToken2(){
        return R.ok().put("msg", "无需token也能访问。。。版本2");
    }


    /**
     * 忽略Token验证测试
     */
    @IgnoreAuth
    @GetMapping("notToken")
    @ApiVersion (3)
    public R notToken3(){
        return R.ok().put("msg", "无需token也能访问。。。 版本3");
    }


}
